﻿
using System;
using System.Net.Mail;


namespace CrazyMan.TM.Interface.Domain
{
    /// <summary>
    /// Represents a player.
    /// </summary>
    public class Player
    {
        private string _firstName;
        private string _lastName;
        private string _nickname;

        /// <summary>
        /// Creates a new player.
        /// </summary>
        public Player()
        {
        }

        /// <summary>
        /// Creates a new player with the specified first and last name.
        /// </summary>
        /// <param name="firstName">The first name of the player.</param>
        /// <param name="lastName">The last name of the player.</param>
        public Player(string firstName, string lastName)
        {
            _firstName = CastNullToString(firstName);
            _lastName = CastNullToString(lastName);
        }

        /// <summary>
        /// Gets and sets the first name of the player.
        /// </summary>
        public string FirstName
        {
            get { return _firstName; }
            set { _firstName = CastNullToString(value); }
        }

        /// <summary>
        /// Gets and sets the last name of the player.
        /// </summary>
        public string LastName
        {
            get { return _lastName; }
            set { _lastName = CastNullToString(value); }
        }

        /// <summary>
        /// Gets and sets the nickname of the player.
        /// </summary>
        public string Nickname
        {
            get { return _nickname; }
            set { _nickname = CastNullToString(value);  }
        }

        /// <summary>
        /// Checks to see if the supplied string is null and if so casts to an empty string and returns it.
        /// </summary>
        /// <param name="value">The string to be checked and cast if necassary.</param>
        protected string CastNullToString(string value)
        {
            if (value == null)
                value = string.Empty;

            return value;
        }
    }
}
